package cn.ac.sec.liquid.subject;

import cn.ac.sec.liquid.common.model.Subject;
import com.jfinal.core.Controller;

public class SubjectController extends Controller {
	
	public void index() {
		setAttr("subjectList", Subject.dao.find("select * from subject"));
		render("subject.html");
	}
	
	public void add() {
	}
	
//	@Before(QuestionValidator.class)
	public void save() {
		Subject subject = getModel(Subject.class);
		subject.save();
		redirect("/subject");
	}
	
	public void edit() {
		setAttr("subject" + "", Subject.dao.findById(getParaToInt()));
	}
	
	public void update() {
		Subject subject = getModel(Subject.class);
		subject.update();
		redirect("/subject");
	}
	
	public void delete() {
		Subject.dao.deleteById(getParaToInt());
		redirect("/subject");
	}
	
	public void batchDelete(){
		String ids[] = getParaValues("ids");
		for(String id : ids){
			Subject.dao.deleteById(Integer.valueOf(id));
		}
		redirect("/subject");
	}
}


